<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/5/12
 * Time: 12:06
 */
include "MySqlConnect.php";
$mysqlconnect = new MySqlConnect();
$jieshou = $_REQUEST["jieshou"];
$openid = $_REQUEST["openid"];
if($jieshou=="checkopenid"){
	$querystr = "select * from user where openid='$openid'";
	$info =json_decode($mysqlconnect->GetDataSetJsonPHP($querystr)) ;
	$count = count($info);
	if($count=="0")
	{
		echo "0";
	}
	else
	{
		echo $info[0]->openid;
	}
}

if($jieshou=="choujiang"){
	date_default_timezone_set('PRC');
	$querystr = "select * from user where openid='$openid' and jiangpin!='0'";
	$info =json_decode($mysqlconnect->GetDataSetJsonPHP($querystr)) ;
	$count = count($info);
	if($count>0){
		echo "1";
	}
	else
	{
		$querystr1 = "select * from user where openid='$openid' and jiangpin='putaogan'";
		$querystr2 = "select * from user where openid='$openid' and jiangpin='rili'";
		$info1 =json_decode($mysqlconnect->GetDataSetJsonPHP($querystr1)) ;
		$count1 = count($info1);
		$info2 =json_decode($mysqlconnect->GetDataSetJsonPHP($querystr2)) ;
		$count2 = count($info2);
		
		$suiji = rand(1,10);
		$jiangpin = "zhufu";
		if($suiji==0 || $suiji==1 || $suiji==2 || $suiji==3){
			$jiangpin = "zhufu";
		}
		if($suiji==4 || $suiji==5 || $suiji==6 || $suiji==7){
			if($count1<20)
			{
				$jiangpin = "putaogan";
			}
		}
		if($suiji==8 || $suiji==9 || $suiji==10){
			if($count1<10)
			{
				$jiangpin = "rili";
			}
		}
		$nowtime = date('Y-m-d H:i:s');
		$jieguo = $mysqlconnect->ExecuteData("update user set jiangpin='$jiangpin' where openid='$openid'");
		echo $jiangpin;
	}
	
	
}

if($jieshou=="tijiao"){
	date_default_timezone_set('PRC');
	$nowtime = date('YmdHis');
	$xingming = $_REQUEST["xingming"];
	$dianhua = $_REQUEST["dianhua"];
	$dizhi = $_REQUEST["dizhi"];
	$jieguo = $mysqlconnect->ExecuteData("update user set xingming='$xingming',dianhua='$dianhua',dizhi='$dizhi',tjtime='$nowtime' where openid='$openid'");
	echo $jieguo;
}

if($jieshou=="yemian")
{
	date_default_timezone_set('PRC');
	$yemian = $_REQUEST["yemian"];$type = $_REQUEST["type"];$nowtime = date('Y-m-d H:i:s');
	$jieguo = $mysqlconnect->ExecuteData("insert into yemian values(null,'$openid','$yemian','$type','$nowtime')");
	echo $jieguo;
}






?>
